{include file="Public:header2"/}

<style type="text/css" media="all">

</style>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form onsubmit="return false;">
                        <div class="layui-form" wid100 lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">分类</label>
                                <div class="layui-input-inline cate1">
                                    <select name="cate_id1" lay-verify="" lay-filter="choose">
                                        <option  value="0">--请选择一级分类--</option>
                                        {foreach name="cate" item="vo"}
                                            <option value="{$vo.id}">{$vo.title}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">排序值</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="sort" value="0"  autocomplete="off" style="width: 600px" placeholder="请输入排序值" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">商品运费</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="yunfei" value="0"  autocomplete="off" style="width: 600px" placeholder="请输入商品运费（0为包邮）" class="layui-input">
                                </div>
                            </div>
                            
                            <div class="layui-form-item">
                                <label class="layui-form-label">99APIKEY</label>
                                <div class="layui-input-inline">
                                     <input type="text" name="apikey"   value="{:session('apikey_id')}" autocomplete="off" style="width: 600px" class="layui-input">
                                     
                                   
                                </div>
                            </div>
                            
                            <div class="layui-form-item">
                                <label class="layui-form-label">商品ID或商品链接</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="url" value="" style="width: 1300px" autocomplete="off" placeholder="请输入商品ID或商品链接" class="layui-input">
                                </div>
                            </div>
                            
                            
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    
                                    <button class="layui-btn" onclick="return check()">确认保存</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
</body>
</html>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    layui.use(['layer','form','upload','laydate'], function(){
        var $ = layui.$;
        var form = layui.form;
    });
    
    var i = 0
    //采集
    function check(){
        var $ = layui.$;
        var url_str = $("#url").val();
        url_arr=url_str.split(","); //字符分割
        var l = url_arr.length
        var url_s = url_arr[i]
        
        var url="{:url('/admin/caiji_save')}";
        var load=layer.load(2);
        var data = $("form").serialize();
        data += '&url='+url_s;
        $.post(url,data,function(data){
            if(data.status==1){
                if(i>=l-1){
                    layer.msg(data.msg,{icon:1,time:1000},function(){
                        location.reload();
                    });
                    return;
                }
                setTimeout(function () {
                    i+=1
                    check();
                },2000)
               
            }else{
                layer.msg(data.msg,{icon:2,anim:6,time:1500},function(){
                    layer.close(load);
                });
            }
        })
    }
</script>